﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ParsingBot
{
	class WebtoonList
	{
		public string id { get; set; }
		public DateTime lastupdate { get; set; }
		public string address { get; set; }
	}
	
	class NaverWebtoonList
	{
		public string id { get; set; }
		public string name { get; set; }

		public bool parseNaverWebtoonList()
		{
			// 목록 갖고오기
			// 
			DBAccess da;
			List<WebtoonList> wl = new List<WebtoonList>();
			foreach (WebtoonList w in wl)
			{
				da = new DBAccess();
				if( da.CheckCompletedWebtoon(w.id) )
					continue;
				
				DataTable updateTimeListTable = da.GetUpdateTimeList(w.id);
				List<string> updateTimeList = new List<string>();
				foreach (DataRow r in updateTimeListTable.Rows)
				{
					updateTimeList.Add(r[0].ToString());
				}
				SaveCurrentCartoon(updateTimeList, w.lastupdate);
			}
			return true;
		}
		
		private void SaveCurrentCartoon(List<string> updateTimeList, DateTime lastUpdate)
		{
			if (DateTime.Parse(updateTimeList[0]) == lastUpdate)
				return;
			else
			{
				SaveCurrentCartoon(updateTimeList, lastUpdate);
			}
			
		}
	}
}
